/***********************************************************
 *  File_Name  : XJListAny.h
 *  File_Path   :
 *  File_Encode : UTF8
 *  Description :
 *
 *  OS : Linux, UNIX
 *  LastVersion  : 20150128
 *
 *  Author      : LiXiujie(李秀杰)
 *  Date        : 2015-1-28
 *  Version     : 20150128
 *  Description :
 *
 *  Edit Author :
 *  Edit Date   :
 *  Version     :
 *  Description :
 *
 ***********************************************************/
#ifndef XJLISTANY_H_
#define XJLISTANY_H_

#include "XJAny.h"
namespace XJUtilClass {
class XJListAny;
class XJListAnyNode{
	XJListAnyNode(){
		pData = 0;
		pPrev = 0;
		pNext = 0;
		pList = 0;
	}
	~XJListAnyNode(){
		if (pData){
			delete pData;
		}
		pData = 0;
		pPrev = 0;
		pNext = 0;
		pList = 0;
	}
protected:
	XJAny *pData;
	XJListAnyNode *pPrev;
	XJListAnyNode *pNext;
	void *pList; // XJListAny
	friend class XJListAny;
private:
	XJListAnyNode(const XJListAnyNode &node){
		pData = 0;
		pPrev = 0;
		pNext = 0;
		pList = 0;
	}
	XJListAnyNode &operator=(const XJListAnyNode &node){
		pData = 0;
		pPrev = 0;
		pNext = 0;
		pList = 0;
		return *this;
	}
};

class XJListAny {
public:
	XJListAny();
	virtual ~XJListAny();
	int Size();
	XJAny &Front();
	XJAny &Back();
	void PopFront();
	void PopBack();
	void Clear();
	void PushFront(const XJAny &any);
	void PushBack(const XJAny &any);
	void Destroy();

	XJListAnyNode* NodeBegin();
	XJListAnyNode* NodeEnd();

	XJListAnyNode* NodePrev(XJListAnyNode *pListNode);
	XJListAnyNode* NodeNext(XJListAnyNode *pListNode);
	XJAny & NodeData(XJListAnyNode *pListNode);

	XJListAnyNode* NodeErase(XJListAnyNode *pListNode);
	XJListAnyNode* NodeAfterInsert(XJListAnyNode *pListNode, const XJAny &pData);
	XJListAnyNode* NodeBeforeInsert(XJListAnyNode *pListNode, const XJAny &pData);
protected:
	XJListAnyNode *pHead;
	XJListAnyNode *pTail;
	int nCount;
};

} /* namespace XJUtilClass */

#endif /* XJLISTANY_H_ */
